package cn.lj.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @file: SwaggerConfiguration.Class
 * @version:
 * @Description: Swagger配置类-knife4j
 * 代码目的，作用，如何工作
 * @author: 李津
 * @date: 2021-04-13 15:37
 * 本代码要注意的事项、备注事项等
 */

/**
 * @author NieChangan
 */
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //这里一定要标注你控制器的位置
                .apis(RequestHandlerSelectors.basePackage("cn.lj.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("lj","https://lijin1998.gitee.io/myblog/","lijin2021@foxmail.com");
        return new ApiInfoBuilder()
                .title("烽火实习-李津-经费管理系统")
                .description("经费管理系统API文档")
                .termsOfServiceUrl("https://lijin1998.gitee.io/myblog/")
                .contact(contact)
                .license("lj-2021")
                .licenseUrl("https://lijin1998.gitee.io")
                .version("1.1")
                .build();
    }
}